from time import time
f=open("m1_sorted.txt")
a=f.readlines()
f.close()
b=[]
for i in range (len(a)) :
    x=int(a[i])
    b.append(x)
def  bubble_sort (a):
    n=len(a)
    for i in range(n-1):
        for j  in range(n-1-i):
            if a[j]>a[j+1]:
                a[j],a[j+1]=a[j+1],a[j]
    return a    
f1=open("m2_reverse.txt")
a1=f1.readlines()
f1.close()
b1=[]
for i1 in range (len(a1)) :
    x1=int(a1[i1])
    b1.append(x1)
def  bubble_sort (a1):
    n1=len(a1)
    for i1 in range(n1-1):
        for j1  in range(n1-1-i1):
            if a1[j1]>a1[j1+1]:
                a1[j1],a1[j1+1]=a1[j1+1],a1[j1]
    return a1
from time import time
f2=open("m3_shuffle.txt")
a2=f2.readlines()
f2.close()
b2=[]
for i2 in range (len(a2)) :
    x2=int(a2[i])
    b2.append(x2)
def  bubble_sort (a2):
    n2=len(a2)
    for i2 in range(n2-1):
        for j2  in range(n2-1-i2):
            if a2[j2]>a2[j2+1]:
                a2[j2],a2[j2+1]=a2[j2+1],a2[j2]
    return a2
t0=time()
c=bubble_sort(b)
t1=time()
print("m1_sorted.txt")
print (round((t1-t0)*1000))
t0=time()
c1=bubble_sort(b1)
t1=time()
print("m2_reverse.txt")
print (round((t1-t0)*1000))
t0=time()
c2=bubble_sort(b2)
t1=time()
print("m3_shuffle.txt")
print (round((t1-t0)*1000))

